package com.atguigu.gulimall.product.feign.fallback;

import com.atguigu.common.exception.BizCodeEnum;
import com.atguigu.common.to.SkuEsModel;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.product.feign.SearchFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @create: 2024/8/29
 * @author: gyhe10
 * @description: SearchFeignService 接口的降级实现类
 **/

@Slf4j
@Component
public class SearchFeignServiceFallback implements SearchFeignService {
    @Override
    public R productStatusToUp(List<SkuEsModel> skuEsModels) {
        List<Long> skuIdList = skuEsModels.stream().map(SkuEsModel::getSkuId).collect(Collectors.toList());
        log.error("调用 search 微服务批量添加商品文档到 ES 失败，涉及商品 ID：{}", skuIdList);
        return R.error(BizCodeEnum.PRODUCT_UP_EXCEPTION.getCode(), BizCodeEnum.PRODUCT_UP_EXCEPTION.getMsg());
    }
}
